package cn.terenas.tool.excel.common.dto.result;

import cn.terenas.tool.excel.common.enums.result.TransferTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.math.BigDecimal;

@Data
@AllArgsConstructor
public class StatisticsResult implements Comparable<StatisticsResult> {

    private String statisticalUnit;

    /**
     * @see TransferTypeEnum#name()
     */
    private TransferTypeEnum transferType;

    private int ntc;

    private int tc;

    private BigDecimal rate;

    public int getTotal() {
        return ntc + tc;
    }

    @Override
    public int compareTo(StatisticsResult statisticsResult) {
        if (statisticsResult != null) {
            if (statisticsResult == this) {
                return 0;
            } else if (this.transferType != null && statisticsResult.getTransferType() != null) {
                return this.transferType.compareTo(statisticsResult.getTransferType());
            }
        }

        return -1;
    }

}
